import reader
import cv2
import numpy as np
import glob

cld_file_path = 'G:/CLP/CLP_2019_0020'+'/NC_H08_20191201_0020_L2CLP010_FLDK.02401_02401.nc'
#rs_file_path = 'G:/2019_0020_nc'+'/NC_H08_20190101_0200_R21_FLDK.06001_06001.nc'

cltype = reader.read_cld(cld_file_path)
#rs_channels = reader.read_rs(rs_file_path)
cltype = cv2.resize(cltype,(6001,6001),interpolation=cv2.INTER_NEAREST)
#rs_img = cv2.merge((rs_channels['albedo_03'],rs_channels['albedo_04'],rs_channels['albedo_05']))

cnt = 0
thr = 0.05
for i in range(11):
    for j in range(13,26):
        #rs_patch = rs_img[i*200:i*200+1000,j*200:j*200+1000]
        cld_patch = cltype[i*200:i*200+1000,j*200:j*200+1000]
        ratio_list = reader.cal_ratio(cld_patch)
        '''
        reader.ndarrdy_to_img((rs_channels['albedo_03'][i*200:i*200+1000,j*200:j*200+1000],
                               rs_channels['albedo_04'][i*200:i*200+1000,j*200:j*200+1000],
                               rs_channels['albedo_05'][i*200:i*200+1000,j*200:j*200+1000]),
                              './crop_test','%2d_%2d.png'%(i,j))
        '''
        if np.max(ratio_list)>=thr:
            print(ratio_list)
            cnt+=1

print(thr,cnt)



